****APPENDIX TABLE F2-F3****

cd "$main_dir/output/tables/appendix_f"

global basic 	marital edu
global econ	    employment_status occupation income imputed_income
global design 	survey_year age language
global polit    ideology party_member

//--------------------------------------------------------
//Read in relevant datasets
//--------------------------------------------------------

clear
use "$data_dir/clean/shp_final_panel.dta"

xtset idpers survey_year

gen dummy = 1 if trust_fed_govt_med!=.
bys idpers: egen total_obs = total(dummy)

cap drop sample
gen sample = 1 if live_switz==1 & total_obs>4 & total_obs!=. & age>=15 & age!=.	

egen canton_survey_year = group(canton survey_year)					
								
//--------------------------------------------------------
//Create Table F2
//--------------------------------------------------------

//Column 1
qui reghdfe trust_fed_govt_med fy_growth_rate yob_ln_gdppc if sample==1 [pw = wicss], absorb(canton $design $basic $econ $polit generation) cluster(idhous yob)
cap drop z*
local varlist trust_fed_govt_med fy_growth_rate yob_ln_gdppc
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_fed_govt_med zfy_growth_rate zyob_ln_gdppc if e(sample)==1 [pw = wicss], absorb(canton $design $basic $econ $polit generation) cluster(idhous yob)
outreg2 using table_f2.doc, replace dec(3) nocons addtext(Canton FE, Yes, ///
														   Survey Year FE, Yes, ///
														   Canton FE x Survey Year FE, No, ///
														   Generation FE, Yes, ///
														   Survey, SHP) keep(zfy_growth_rate) 		
		
//Column 2
qui reghdfe trust_fed_govt_med fy_growth_rate yob_ln_gdppc if sample==1 [pw = wicss], absorb(canton_survey_year $design $basic $econ $polit generation) cluster(idhous yob)
cap drop z*
local varlist trust_fed_govt_med fy_growth_rate yob_ln_gdppc
foreach var of local varlist {
	egen z`var' = std(`var') if e(sample)==1
}
reghdfe ztrust_fed_govt zfy_growth_rate zyob_ln_gdppc if e(sample)==1 [pw = wicss], absorb(canton_survey_year $design $basic $econ $polit generation) cluster(idhous yob)
outreg2 using table_f2.doc, append dec(3) nocons addtext(Canton FE, No, ///
														   Survey Year FE, No, ///
														   Canton FE x Survey Year FE, Yes, ///
														   Generation FE, Yes, ///
														   Survey, SHP) keep(zfy_growth_rate)

//--------------------------------------------------------
//Create Table F3
//--------------------------------------------------------													   		   

//Column 1
qui reghdfe trust_fed_govt_med preyob_growth_rate_5 yob_ln_gdppc if sample==1 [pw = wicss], absorb(canton $design $basic $econ $polit generation) cluster(idhous yob)
local list trust_fed_govt_med preyob_growth_rate_5 yob_ln_gdppc
cap drop z*
foreach x of local list {
	egen z`x' = std(`x') if e(sample)==1
}
reghdfe ztrust_fed_govt_med zpreyob_growth_rate_5 zyob_ln_gdppc if e(sample)==1 [pw = wicss], absorb(canton $design $basic $econ $polit generation) cluster(idhous yob)
outreg2 using table_f3.doc, replace dec(3) nocons addtext(Canton FE, Yes, ///
														   Generation FE, Yes, ///
														   Survey Year FE, Yes, ///
														   Survey, SHP) keep(zpreyob_growth_rate_5) 

//Columns 2-3														   
local varlist preyob_growth_rate_10 preyob_growth_rate_15
foreach var of local varlist {
	
	qui reghdfe trust_fed_govt_med `var' yob_ln_gdppc if sample==1 [pw = wicss], absorb(canton $design $basic $econ $polit generation) cluster(idhous yob)
	
	local list trust_fed_govt_med `var' yob_ln_gdppc
	cap drop z*
	foreach x of local list {
		egen z`x' = std(`x') if e(sample)==1
	}
	
	reghdfe ztrust_fed_govt_med z`var' zyob_ln_gdppc if e(sample)==1 [pw = wicss], absorb(canton $design $basic $econ $polit generation) cluster(idhous yob)
	outreg2 using table_f3.doc, append dec(3) nocons addtext(Canton FE, Yes, ///
														   Generation FE, Yes, ///
														   Survey Year FE, Yes, ///
														   Survey, SHP) keep(z`var') 								
}

